package me.luraframework.auth.security;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@Slf4j
@RequiredArgsConstructor
public class TokenFilter extends OncePerRequestFilter {

    private final TokenProvider tokenProvider;



    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        String token = tokenProvider.getToken(request);
        log.info("api request: {}, token: {}", request.getRequestURI(), token);
        // JwtUserDto jwtUser = tokenProvider.checkToken(tokenProvider.getToken((HttpServletRequest) servletRequest));
        // SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(jwtUser, "****", new ArrayList<>()));
        filterChain.doFilter(request, response);
    }


}
